﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using STT.Entities;
using STT.DataAccess;


namespace STT.Business
{
    public class BTbCongViec
    {
        public static DataTable SelectAll()
        {
            DataTable all = SqlHelper.ExecuteData(CommandType.StoredProcedure, "TbCongViec_SelectAll", null);
            return all;
        }
        public static DataTable CheckTimeDT(DateTime ThoiGianThi)
        {
            SqlParameter[] pr = new SqlParameter[1];
            pr[0] = new SqlParameter(@"ThoiGianThi", ThoiGianThi);
            DataTable all = SqlHelper.ExecuteData(CommandType.StoredProcedure, "TbCongViec_CheckTimeDT", pr);
            return all;
        }
        public static DataTable SelectByMHMaGVMaLop(string MaGV, string MaMH, string MaLop,string LoaiCV)
        {
            SqlParameter[] pr = new SqlParameter[4];
            pr[0] = new SqlParameter(@"MaGV", MaGV);
            pr[1] = new SqlParameter(@"MaMH", int.Parse(MaMH));
            pr[2] = new SqlParameter(@"MaLop ", int.Parse(MaLop));
            pr[3] = new SqlParameter(@"LoaiCV ", int.Parse(LoaiCV));
            DataTable all = SqlHelper.ExecuteData(CommandType.StoredProcedure, "TbCongViec_SelectByMHMaGVMaLopMaLoaiCV", pr);
            return all;
        }
        
        //-----------------------------------------------------------//
        public static void InsertCongViecCoiThi(ETbCongViec OTbCongViec )
        {
            SqlParameter[] pr = new SqlParameter[11];
            pr[0] = new SqlParameter(@"NDCongViec", OTbCongViec.NDCongViec);
            pr[1] = new SqlParameter(@"MaLop", OTbCongViec.MaLop);
            pr[2] = new SqlParameter(@"MaMonHoc", OTbCongViec.MaMonHoc);
            pr[3] = new SqlParameter(@"MaGV", OTbCongViec.MaGV);
            pr[4] = new SqlParameter(@"ThoiGianBatDau", OTbCongViec.ThoiGianBatDau);
            pr[5] = new SqlParameter(@"ThoiGianKetThuc", OTbCongViec.ThoiGianKetThuc);
            pr[6] = new SqlParameter(@"TrangThai", OTbCongViec.TrangThai);
            pr[7] = new SqlParameter(@"NgayCoiThi", OTbCongViec.NgayCoiThi);
            pr[8] = new SqlParameter(@"CaThi", OTbCongViec.CaThi);
            pr[9] = new SqlParameter(@"PhongThi", OTbCongViec.PhongThi);
            pr[10] = new SqlParameter(@"LoaiCV", OTbCongViec.LoaiCongViec);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "TbCongViec_InsertCoiThi", pr);
        }
        //-----------------------------------------------------------//
        public static void InsertCongViecChamThi(ETbCongViec OTbCongViec)
        {
            SqlParameter[] pr = new SqlParameter[10];
            pr[0] = new SqlParameter(@"NDCongViec", OTbCongViec.NDCongViec);
            pr[1] = new SqlParameter(@"MaLop", OTbCongViec.MaLop);
            pr[2] = new SqlParameter(@"MaMonHoc", OTbCongViec.MaMonHoc);
            pr[3] = new SqlParameter(@"MaGV", OTbCongViec.MaGV);
            pr[4] = new SqlParameter(@"ThoiGianBatDau", OTbCongViec.ThoiGianBatDau);
            pr[5] = new SqlParameter(@"ThoiGianKetThuc", OTbCongViec.ThoiGianKetThuc);
            pr[6] = new SqlParameter(@"TrangThai", OTbCongViec.TrangThai);
            pr[7] = new SqlParameter(@"NgayNhanBaiThi", OTbCongViec.NgayNhanBaiThi);
            pr[8] = new SqlParameter(@"NgayNopKQChamThi", OTbCongViec.NgayNopKQChamThi);
            pr[9] = new SqlParameter(@"LoaiCV", OTbCongViec.LoaiCongViec);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "TbCongViec_InsertChamThi", pr);
        }
        //-----------------------------------------------------------//
        public static void InsertCongViecRaDe(ETbCongViec OTbCongViec)
        {
            SqlParameter[] pr = new SqlParameter[10];
            pr[0] = new SqlParameter(@"NDCongViec", OTbCongViec.NDCongViec);
            pr[1] = new SqlParameter(@"MaLop", OTbCongViec.MaLop);
            pr[2] = new SqlParameter(@"MaMonHoc", OTbCongViec.MaMonHoc);
            pr[3] = new SqlParameter(@"MaGV", OTbCongViec.MaGV);
            pr[4] = new SqlParameter(@"ThoiGianBatDau", OTbCongViec.ThoiGianBatDau);
            pr[5] = new SqlParameter(@"ThoiGianKetThuc", OTbCongViec.ThoiGianKetThuc);
            pr[6] = new SqlParameter(@"TrangThai", OTbCongViec.TrangThai);
            pr[7] = new SqlParameter(@"NgayRaDe", OTbCongViec.NgayRaDe);
            pr[8] = new SqlParameter(@"LoaiCV", OTbCongViec.LoaiCongViec);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "TbCongViec_InsertRaDe", pr);
        }
        //-----------------------------------------------------------//
    }
}